package com.front.managementfront.driver.controller;


import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.front.managementfront.driver.entity.CertificateImg;
import com.front.managementfront.driver.service.ICertificateImgService;
import com.front.managementfront.utils.CustomPageUtils;
import com.hkts.management.common.utils.Result;
import com.hkts.management.common.utils.ResultUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;

/**
 * @author yck
 * @since 2021-11-19
 */
@RestController
@RequestMapping("/front/certificateImg")
public class CertificateImgController {
    private final Logger logger = LoggerFactory.getLogger(CertificateImgController.class);

    @Autowired
    public ICertificateImgService iCertificateImgService;

    /**
     * 分页查询数据
     *
     * @param page           分页信息
     * @param certificateImg 查询条件
     * @return
     */
    @ResponseBody
    @GetMapping("/getCertificateImgPageList")
    public Result<Object> getHontUserList(Page<CertificateImg> page, CertificateImg certificateImg) {
        return ResultUtil.data(CustomPageUtils.getCustomPage(iCertificateImgService.selectPage(page, certificateImg)));
    }

    /**
     * 保存和修改公用的
     *
     * @param certificateImg 传递的实体
     * @return saveOrUpdate
     */
    @ResponseBody
    @RequestMapping(method = RequestMethod.POST, value = "/certificateImgSave")
    public Result<Object> certificateImgSave(CertificateImg certificateImg) {
        iCertificateImgService.saveOrUpdate(certificateImg);
        return ResultUtil.success("保存成功");
    }

    /**
     * 根据id获取对象
     *
     * @param id 实体ID
     * @return 0 失败  1 成功
     */
    @ResponseBody
    @RequestMapping(method = RequestMethod.GET, value = "/certificateImgGetById")
    public Result<Object> certificateImgGetById(String id) {
        CertificateImg byId = iCertificateImgService.getById(id);
        return ResultUtil.data(byId);
    }

    /**
     * 根据id删除对象
     *
     * @param id 实体ID
     * @return 0 失败  1 成功
     */
    @ResponseBody
    @RequestMapping(method = RequestMethod.POST, value = "/certificateImgDelete")
    public Result<Object> hontUserDelete(String id) {
        iCertificateImgService.removeById(id);
        return ResultUtil.success("删除成功");
    }

    /**
     * 批量删除对象
     *
     * @param item 实体集合ID
     * @return 0 失败  1 成功
     */
    @ResponseBody
    @RequestMapping(method = RequestMethod.POST, value = "/certificateImgBatchDelete")
    public Result<Object> deleteBatchIds(String item) {
        List<String> ids = (List<String>) JSON.parse(item);
        iCertificateImgService.removeByIds(ids);
        return ResultUtil.success("删除成功");
    }
    /** 功能描述:
    *
    * @return: 
    * @Author: 杨春科
    * @Date: 2021-11-19 15:12
    * @Description //TODO 
    */
    @ResponseBody
    @RequestMapping(method = RequestMethod.POST, value = "/dadaHandler")
    public Result dadaHandler(){
        iCertificateImgService.dadaHandler();
        return ResultUtil.success("数据处理成功");
    }

}
